QuickOPC User's Guide and Reference
Always test the HasValue property before accessing DAVtq.Value or UAAttributeData.Value
Best Practices > Always test the HasValue property before accessing DAVtq.Value or UAAttributeData.Value

The controlling member in the DAVtq class (OPC Data Access Value/Timestamp/Quality) is the Quality property. When the quality is not sufficient, the Value property is not available (and QuickOPC assures that is a null reference in this case). Getting the Value property when it is not available makes little sense.

The same applies to the UAAttributeData class (in OPC Unified Architecture) with regard to its StatusCode and Value properties.

It is commonly said that the value is available whenever the quality (or status code) is not Bad, but precisely speaking, this is not true, as there are some border cases (per OPC specifications) in which this rule does not apply. Your best choice is to test the HasValue property, which has the precise, OPC-compliant functionality built in. Only if HasValue is true, the Value property contains valid data.

For more information, see Data Objects.

See Also